package odgs.message.client;

import java.util.HashMap;

import odgs.Connection;
import odgs.GridState;
import odgs.message.Message;
import odgs.message.MessageHandler;
import odgs.message.MessageProcessor;
import odgs.transaction.ContentsRemoveTransaction;

public class ContentsRemoveTransactionResponseHandler implements MessageHandler
{
	public void execute(MessageProcessor processor, Message msg, Connection con)
	{
		if(msg.getResult() < 0)
		{
			ContentsRemoveTransaction trans =  (ContentsRemoveTransaction) msg.get("transaction");
			processor.getTransactionManager().error(msg.getResult(), trans);
		}
		else
		{
			ContentsRemoveTransaction trans = (ContentsRemoveTransaction) msg.get("transaction");
			GridState state = (GridState) msg.get("state");

			processor.getDataManager().removeContents(trans.getDest());
			processor.getDataManager().setGridState(state);
			processor.getTransactionManager().doneTransaction(trans.getRequestId());
		}
	}
}